<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>{$info.title}</title>
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/weui.css"/>

    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/mycord/css/paycards.css" />
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/setpaycard.css" />

</head>
<body>
<div class="content">
    <div class="page__bd">
        <div class="commodityImgBox">
            <img src="{$info.img}" alt="商品图片" class="commodityImg">
        </div>
        <div class="mtop10 commodityIntroBox">
            <span class="color1 c-inlineblock c-aligh-left goodsjianjie">{$info.goodsjianjie}</span>
        </div>
        <div class="mtop5 color6 commodityUnivalenceBox">

            <span class="fsize10" style="font-size:12px;">¥</span>
            <span class="commodityUnivalence price">{$info['price']}</span>

        </div>
        <div class="mtop5 color6 commodityUnivalenceBox">

            <span class="fsize10">剩余数量:{$info['num']-$info['get_num']}</span>
        </div>
        <div class="mtop5 color6 commodityUnivalenceBox">
            <span class="fsize10">每人限购:{$info.homebuy}次</span>
        </div>
        <div class="pad20">
            <div class="c-line"></div>
        </div>
        <div class="commodityDescBox c-aligh-left">

            {$info.goodsinfo}
            <sqan class="jus"></sqan>
        </div>

            <div class="btn">
                <input type="hidden" name="get_card_id" id="id" value="{$user.id}">
                <input type="hidden" name="fid" id="num" value="{$info.num}">
                <input type="hidden" name="fid" id="get_num" value="{$info.get_num}">
                <input type="hidden" name="fid" id="fid" value="{$info.id}">
                <input type="hidden" name="openid" id="openid" value="{$user.openid}">
                {eq name="$info['status']" value="1"}
                    {eq name=":filterpaycard($info['starttime'],$info['endtime'])" value="0"}
                        {eq name=":getpaysum($user['openid'],$info['id'])" value="0"}
                            {eq name="$info['stocks']" value="0"}
                                <button class="weui-btn weui-btn_default" id="weui-btn_default" style="background: #eee;">已售完</button>
                            {else/}
                                <button class="weui-btn weui-btn_primary " id="weui-btn_primary">支付{$info['price']}元</button>
                                <button class="weui-btn weui-btn_default" id="weui-btn_default" style="display:none;background: #eee;">支付{$info['price']}元</button>
                            {/eq}
                            {else/}
                <a class="weui-btn weui-btn_default" id="weui-btn_default" href="{:url('cardusernu/mecard',['mid'=>$info['mid'] ])}" style="background: #eee;">您已经领取，请在微信卡包里查看</a>
                        {/eq}
                    {else/}
                        <button class="weui-btn weui-btn_default" id="weui-btn_default" style="background: #eee;">不在活动时间</button>
                    {/eq}
                {else/}
                    <button class="weui-btn weui-btn_default" id="weui-btn_default" style="background: #eee;">该商品已下架</button>
                {/eq}
            </div>

    </div>

</div>

<!----->
<div id="dialogt">
    <div class="js_dialog" id="iosDialog3" style="opacity: 1; display: none; z-index: 999;">
        <div class="weui-mask">
        </div>
        <div class="weui-dialog">
            <div class="weui-dialog__bd">
                <div class="bgfff chakan" >
                    <p class="ku"></p>
                </div>
            </div>
            <div class="weui-dialog__ft">

                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确认</a>
            </div>
        </div>
    </div>
</div>

</body>
<script src="__STATIC_URL__/static/jquery/3.2.1/jquery.min.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

    <script type="text/javascript" id="tpl_dialog">
        $(function(){


            $('#dialogt').on('click', '.weui-dialog__btn', function(){
                $(this).parents('.js_dialog').fadeOut(200);
            });

        });
</script>
<script>
    $(function(){

        var get_num=parseInt($('#get_num').val());
        var num=parseInt($('#num').val());
        if(num == get_num){
            $("#weui-btn_primary").attr("style","display:none");
            $("#weui-btn_default").attr("style","display:block");

        }
    });
</script>
<script type="text/javascript">
    $(".weui-btn_primary").click(function () {
        var fid = $('#fid').val();
        var openid = $('#openid').val();
        var get_card_id=$('#id').val();
        var get_num=parseInt($('#get_num').val());
        var num=parseInt($('#num').val());


        if(num>get_num){

        $.ajax({
            url: "{:url('cardshop/addorder')}",
            type: 'post',
            dataType: 'json',
            data: {
                id: fid,
                openid: openid,
                get_card_id:get_card_id
            },

            success: function (data) {


                // return;
                if(data.code==0){
                    var url=data.data.url;
                    window.location.replace(url);
                    return;
                }
                if(data.code=='9003'){
                    alert(data.message);
                    return;
                }

            }
        })
        }else{
            $("#weui-btn_primary").attr("style","display:none");
            $("#weui-btn_default").attr("style","display:block");
            $(".ku").html("该商品没有库存！");
            $("#iosDialog3").fadeIn(200);
        }
    })



</script>
</html>
